var koa = require("koa");
var Router = require("koa-router")
var views = require("koa-views")
var bodyParser = require("koa-bodyparser")

var app = new koa();
var router = new Router();

app.use(views('views',{
    extension:'ejs'
}));



//配置 post bodyparser 中间件
app.use(bodyParser());

router.get('/', async (ctx) => {
    var title = "hello world";
    var arr = [111, 222, 333];
    var content = "<h2>这是一个带标签的文字</h2>";
    num = 5;
    await ctx.render('index',{title,arr,content,num})

});


// 接收post提交的数据

router.post('/doAdd', async (ctx)=>{
    ctx.body = ctx.request.body;
});




app.use(router.routes());
app.use(router.allowedMethods);


app.listen(3000);


